// /////////////////////////////////////////////////////////////////////////////
//
// Name:            BillboardComponent.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the BillboardComponent class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __BILLBOARDCOMPONENT_H__
#define __BILLBOARDCOMPONENT_H__

// Include files
#include "../../dependencies.h"
#include "SceneComponent.h"


// BillboardComponent class
//! Component wrapper of Irrlicht's IBillboardSceneNode.
class BillboardComponent : public SceneComponent
{
public:

    // Initialisation and deinitialisation
    //! Constructor (default)
    //! @param parent        The parent entity to which the component should be added.
    //! @param size          2 dimensional size of the billboard.
    //! @param colorTop      The color of the vertices at the top of the billboard.
    //! @param colorBottom   The color of the vertices at the bottom of the billboard.
    BillboardComponent(Entity *parent, const dimension2df &size = dimension2df(10.0f, 10.0f),
                       const SColor &colorTop = SColor(255, 255, 255, 255),
                       const SColor &colorBottom = SColor(255, 255, 255, 255));
    //! Deconstructor
    ~BillboardComponent();

    // Methods
    //! Returns a direct pointer to the IBillboardSceneNode.
    //! @note Not available in AngelScript.
    IBillboardSceneNode* getBillboardSceneNode();

    //! Gets the color of the top and bottom vertices of the billboard.
    //! @param topColor      SColor object in which the top color will be stored.
    //! @param bottomColor   SColor object in which the bottom color will be stored.
    void getColor(SColor &topColor, SColor &bottomColor) const;
    //! Returns the size of the billboard.
    const dimension2df& getSize() const;

    //! Sets the color of all vertices of the billboard.
    //! @param overallColor  The color to set.
    void setColor(const SColor &overallColor);
    //! Sets the color of the top and bottom vertices of the billboard.
    //!
    //! <b>XML:</b>
    //! \code
    //! <color>
    //!    <topColor type="color" value="" />
    //!    <bottomColor type="color" value="" />
    //! </color>
    //! \endcode
    //!
    //! @param topColor      The color to set the top vertices.
    //! @param bottomColor   The color to set the bottom vertices.
    void setColor(const SColor &topColor, const SColor &bottomColor);
    //! Sets the size of the billboard.
    //!
    //! <b>XML:</b>
    //! \code
    //! <size type="dimension2d" value="" />
    //! \endcode
    //!
    //! @param size          Size of the billboard.
    void setSize(const dimension2df &size);

    // Serialization
    //! Serializes this object.
    //! @param attributes
    virtual bool onSerialization(SerializedAttributes *attributes);
    //! Deserializes this object.
    //! @param attributes
    virtual bool onDeserialization(SerializedAttributes *attributes);

protected:

    // Initialisation
    //! Constructor for derived classes.
    BillboardComponent(Entity *parent, bool isDerived);

    // Members
    IBillboardSceneNode *mBillboardSN;
};

#endif
